﻿using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;

namespace EyFramework.ORM
{
    public class TjDbHelper
    {
        public static BaseDaoTj<object> baseDaoTj = new BaseDaoTj<object>();

        /// <summary>
        /// 执行SQL语句
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataTable SelectTable(string sql)
        {
            return baseDaoTj.Db.Ado.GetDataTable(sql);
        }

        /// <summary>
        /// 执行带参数的SQL语句
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="sqlParameters"></param>
        /// <returns></returns>
        public static DataTable SelectTable(string sql, SugarParameter[] sqlParameters)
        {
            return baseDaoTj.Db.Ado.GetDataTable(sql, sqlParameters);
        }

        /// <summary>
        /// 执行DML更新语句
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static int ExecuteUpdate(string sql)
        {
            return baseDaoTj.Db.Ado.ExecuteCommand(sql);
        }

        /// <summary>
        /// 执行更新带参数
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="sqlParameters"></param>
        /// <returns></returns>
        public static int ExecuteUpdate(string sql, SugarParameter[] sqlParameters)
        {
            return baseDaoTj.Db.Ado.ExecuteCommand(sql, sqlParameters);
        }
    }
}